export default {
	debounce(fn, delay) {
		var delay = delay || 200;
		var timer;
		return function() {
			var th = this;
			var args = arguments;
			if (timer) {
				clearTimeout(timer);
			}
			timer = setTimeout(() => {
				timer = null;
				fn.apply(th, args);
			}, delay);
		};
	},
	dateFormate(time, type) {
		var temp = new Date(time)
		//yyyy-mm-dd
		var date = [temp.getFullYear(),
			temp.getMonth() + 1 >= 9 ? temp.getMonth() + 1 : '0' + (temp.getMonth() + 1).toString(),
			temp.getDate() >= 9 ? temp.getDate() : '0' + temp.getDate().toString()
		]

		if (type == 'yyyy-mm-dd') {
			return date.join('-')
		}
	}
}
